﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Business.FlowOperation;
using Business.Admin;
using WF_Business;
using Business;

public partial class frmMainNew : PageBase
{
    public string strYjurl12;
    public int YgqNum;
    public string YgqHtml;
    public int JjgqNum;
    public string JjgqHtml;
    public string strYjLburl;
    public int strAjGqNum;
    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!IsPostBack)
        {  
            if (!string.IsNullOrEmpty(UserName))
            {
                //获取设置标题头
                string strMsg = "<script>function initWinInfo(){"; 
                //设置待办件的地址
                strMsg += "addTab(strFirstUrl,strFirstUrlName);";

                strMsg += string.Format("loadTitle('divCenter','业务办公区【欢迎您，{0}，今天是{1}】');HideLoading();", UserName, DateTime.Now.ToShortDateString());

                RequestFlowOperation flowOperation = new RequestFlowOperation();
                DataTable dtSource = flowOperation.AppearWorkItem(UserId, "");
                DataRow[] DrYgq = dtSource.Select("督办过期<0");
                //获取已超期办件详情
                //DataTable newDrYgq = new DataTable();
                //newDrYgq = newDrYgq.Clone(); // 克隆dt 的结构，包括所有 dt 架构和约束,并无数据； 
                //DataRow[] DrYgq = dtSource.Select("督办过期<0"); // 从dt 中查询符合条件的记录； 
                //for (int i = 0; i < DrYgq.Length; i++)
                //{
                //    newDrYgq.ImportRow((DataRow)DrYgq[i]);
                //}
                YgqNum = DrYgq.Count(); //获取已超期案件条数
                DataRow[] DrJjgq = dtSource.Select("结点过期<0");
                JjgqNum = DrJjgq.Count();//获取将过期件条数
                //获取待办件的条数
                int TiaoShu = dtSource.Rows.Count;
                Session["TiaoShu"] = TiaoShu;

                //获取业务编号和业务名称  所在岗位
                string strDbMsg = "";
                
                if (TiaoShu > 0) {
                    for (int i = 0; i < TiaoShu; i++) {
                        strDbMsg += "<a href=\"Office/TaskProcess.aspx?ItemId=";
                        strDbMsg += dtSource.Rows[i]["WIID"];
                        strDbMsg += "&iid=";
                        strDbMsg += dtSource.Rows[i]["顺序号"];
                        strDbMsg += "&step=";
                        strDbMsg += dtSource.Rows[i]["所在岗位"];
                        strDbMsg += "\" class=\"ellipsis\" target=\"_blank\">编号：";
                        strDbMsg += dtSource.Rows[i]["顺序号"];
                        strDbMsg += "</span>&nbsp;&nbsp;";
                        strDbMsg += dtSource.Rows[i]["案件类型"];
                        strDbMsg += "<i></i></a><label>";
                        //strDbMsg += FormatDateTime(rs(dtSource.Rows[i]["接收时间"]),2);
                        strDbMsg += dtSource.Rows[i]["接收时间"];
                        strDbMsg += "</label>";
                    }
                }
                Session["strDbMsg"] = strDbMsg;

                //获取已超期的案件内容
                //if (YgqNum>0) {
                //    YgqHtml = "";
                //    for (int i = 0; i < YgqNum; i++) {
                //        YgqHtml += string.Format(@"<a href=""Office/TaskProcess.aspx?ItemId={1}&iid={2}&step={3}"" class=""ellipsis"" target=""_blank"">编号：{2}</span>&nbsp;&nbsp;{4} <i></i></a><label>{5}</label>", i, newDrYgq.Rows[i]["WIID"], newDrYgq.Rows[i]["顺序号"], newDrYgq.Rows[i]["所在岗位"], newDrYgq.Rows[i]["案件类型"], newDrYgq.Rows[i]["接收时间"]);
                //    }
                //}
                //获取待接收短消息
                //< a href = "javascript:;" class="ellipsis">您有<span>2条</span> 供应商开发申请未处理<i></i></a>
                string strPopContent = "<table>";
                strPopContent += string.Format("<tr><td><a href=javascript:addTab('MyWindow/TaskInStepList.aspx','接收即时消息')>您有{0}条待办审核</a></td></tr>", dtSource.Rows.Count);
                strPopContent += "</table>";
                strMsg += string.Format("loadMsg(\"{0}\");", strPopContent);

                //针对
                strMsg += "}</script>";

                Response.Write(strMsg);
                //获取通知公告
                string strTzgg = "";
                ClsInfoManage imTemp = new ClsInfoManage();
                DataTable dtSource1 = imTemp.GetAllInfo("通知公告", "");
                DataTable dtSource2 = imTemp.GetAllInfo("新闻", "");
                DataTable dtSource3 = imTemp.GetAllInfo("下载中心", "");
                if (dtSource1.Rows.Count > 0) {
                    for (int i = 0; i < dtSource1.Rows.Count; i++) {
                        strTzgg += string.Format(@"<li> <span></span> <a href = ""MyWindow/TzggInfoDetail.aspx?id={3}""  target=""_blank"" class=""ellipsis"">{1}<i></i></a> </li>", i, dtSource1.Rows[i]["BT"], dtSource1.Rows[i]["FBSJ"], dtSource1.Rows[i]["ID"]);
                    }
                }
                Session["strTzgg"] = strTzgg;
                //获取新闻信息
                string strXwxx = "";
                if (dtSource2.Rows.Count > 0)
                {
                    for (int i = 0; i < dtSource2.Rows.Count; i++)
                    {
                        strXwxx += string.Format(@"<li> <span></span> <a href = ""MyWindow/TzggInfoDetail.aspx?id={3}""  target=""_blank"" class=""ellipsis"">{1}<i></i></a> </li>", i, dtSource2.Rows[i]["BT"], dtSource2.Rows[i]["FBSJ"], dtSource2.Rows[i]["ID"]);
                    }
                }
                Session["strXwxx"] = strXwxx;
                //获取新闻信息
                string strXzzx = "";
                if (dtSource3.Rows.Count > 0)
                {
                    for (int i = 0; i < dtSource3.Rows.Count; i++)
                    {
                        strXzzx += string.Format(@"<li> <span></span> <a href = ""MyWindow/TzggInfoDetail.aspx?id={3}""  target=""_blank"" class=""ellipsis"">{1}<i></i></a> </li>", i, dtSource3.Rows[i]["BT"], dtSource3.Rows[i]["FBSJ"], dtSource3.Rows[i]["ID"]);
                    }
                }
                Session["strXzzx"] = strXzzx;
                //获取邮件信息查看地址
                string strYjurl = "";
                DataTable dtSourceYj = GetChildMenu("发件箱");
                if (dtSourceYj.Rows.Count > 0)
                {
                    strYjurl += dtSourceYj.Rows[0]["Linkhref"];
                }
                strYjurl = strYjurl.Replace("{CjFlowPage}", SystemConfig.NewActivexAppearUrl);
                strYjurl = strYjurl.Replace("{userid}", UserId);
                // Session["strYjurl"] = strYjurl;
                strYjurl12 = strYjurl;
                //获取邮件信息列表查看地址
                strYjLburl = "";
                DataTable dtSourceYjLb = GetChildMenu("收件箱");
                if (dtSourceYj.Rows.Count > 0)
                {
                    strYjLburl += dtSourceYj.Rows[0]["Linkhref"];
                }
                strYjLburl = strYjurl.Replace("{CjFlowPage}", SystemConfig.NewActivexAppearUrl);
                strYjLburl = strYjurl.Replace("{userid}", UserId);
                //获取案件挂起的个数
                SuspendLogInfo suInfo = new SuspendLogInfo();
                DataTable dtSourceGq = suInfo.GetSuspendLog(UserId, "", "", "");
                strAjGqNum =dtSourceGq.Rows.Count;
            }
        }
    }
    /// <summary>
    /// 信息条数，存贮在Session中
    /// </summary>
    protected string TiaoShu
    {
        get
        {
            if (Session["TiaoShu"] != null)
            {
                return Session["TiaoShu"].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
    }
    /// <summary>
    /// 具体待办信息详情，存贮在Session中
    /// </summary>
    protected string strDbMsg
    {
        get
        {
            if (Session["strDbMsg"] != null)
            {
                return Session["strDbMsg"].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
    }
    /// <summary>
    /// 通知公告，存贮在Session中
    /// </summary>
    protected string strTzgg
    {
        get
        {
            if (Session["strTzgg"] != null)
            {
                return Session["strTzgg"].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
    }
    /// <summary>
    /// 新闻信息，存贮在Session中
    /// </summary>
 /// <summary>
    protected string strXwxx
    {
        get
        {
            if (Session["strXwxx"] != null)
            {
                return Session["strXwxx"].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
    }
    /// <summary>
    /// 下载中心，存贮在Session中
    /// </summary>
    /// <summary>
    protected string strXzzx
    {
        get
        {
            if (Session["strXzzx"] != null)
            {
                return Session["strXzzx"].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
    }
    /// <summary>
    /// 邮件查看，存贮在Session中
    /// </summary>
    /// <summary>
    protected string strYjurl
    {
        get
        {
            if (Session["strYjurl"] != null)
            {
                return Session["strYjurl"].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
    }
    /// <summary>
    /// 根据菜单名称获取子菜单地址
    /// </summary>
    /// <param name="strMenu_child_desc">子菜单名称</param>
    /// <returns></returns>
    public DataTable GetChildMenu(string strMenu_child_desc)
    {
        string strSql = string.Format("select * from xt_menu_child where Menu_child_desc='{0}'",strMenu_child_desc);
        DataTable dt = null;
        SysParams.OAConnection().RunSql(strSql, out dt);
        return dt;
    }
}
